package com.nc.shop.service.model.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
@ApiModel("商品")
public class ShopEntity {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name = "NumberIdProduce", strategy = "com.plug.idProduce.NumberIdProduce")
    private String id;

    @Column
    @ApiModelProperty("名称")
    private String name;

    @Column
    @Lob
    @ApiModelProperty("图片")
    private String image;

    @Column
    @ApiModelProperty("标签")
    private String icon;

    @Lob
    @Column
    @ApiModelProperty("详情")
    private String note;

    @Column
    @ApiModelProperty("状态")
    private Boolean status;

    @Column
    @ApiModelProperty("单位")
    private String unit;

    @Column
    @ApiModelProperty("市场价")
    private BigDecimal makePrice;

    @Column
    @ApiModelProperty("种植成熟时间（秒）")
    private Long ripe;

    @Column
    @ApiModelProperty("现价")
    private BigDecimal price;

    @ApiModelProperty("品牌")
    @Column
    private String brand;

    @Column
    @ApiModelProperty("产地")
    private String place;

    @ManyToOne
    private ClassifyEntity classify;

    @CreatedDate
    @Column
    private Date createTime;

    @LastModifiedDate
    @Column
    private Date modifiedTime;

    @Column(columnDefinition = "int default 0")
    @ApiModelProperty("库存数量")
    private Integer repertory;

    @OneToMany
    private List<RepertoryEntity> repertoryEntities;
}
